<template>
  <div class="dashboard">
    <el-card class="welcome-card">
      <h2 class="welcome-title">
        <i class="el-icon-s-goods theme-icon"></i>
        欢迎登录WMS系统,亲爱的用户！（本页面待优化，留到最后）
      </h2>
    </el-card>
    <!-- KPI 指标区域 -->
    <div class="kpi-section">
      <div class="kpi-card">
        <div class="kpi-icon blue">
          <el-icon>
            <ArrowDown />
          </el-icon>
        </div>
        <div class="kpi-content">
          <div class="kpi-value">10086</div>
          <div class="kpi-label">总货品量</div>
        </div>
      </div>

      <div class="kpi-card">
        <div class="kpi-icon green">
          <el-icon>
            <ArrowUp />
          </el-icon>
        </div>
        <div class="kpi-content">
          <div class="kpi-value">10086</div>
          <div class="kpi-label">仓库空余</div>
        </div>
      </div>

      <div class="kpi-card">
        <div class="kpi-icon purple">
          <el-icon>
            <List />
          </el-icon>
        </div>
        <div class="kpi-content">
          <div class="kpi-value">10086</div>
          <div class="kpi-label">待入库任务</div>
        </div>
      </div>

      <div class="kpi-card">
        <div class="kpi-icon orange">
          <el-icon>
            <Money />
          </el-icon>
        </div>
        <div class="kpi-content">
          <div class="kpi-value">¥10086</div>
          <div class="kpi-label">待收费金额</div>
        </div>
      </div>

      <div class="kpi-card">
        <div class="kpi-icon red">
          <el-icon>
            <User />
          </el-icon>
        </div>
        <!-- <div class="kpi-content">
          <div class="kpi-value">¥356</div>
          <div class="kpi-label">待核销金额</div>
        </div> -->
      </div>
    </div>

    <!-- 主要内容区域 -->
    <div class="main-content">
      <!-- 左侧常用功能 -->
      <div class="left-section">
        <h3 class="section-title">常用功能</h3>
        <div class="function-grid">
          <div class="function-card blue">
            <el-icon>
              <Download />
            </el-icon>
            <span>新建入库单</span>
          </div>
          <div class="function-card green">
            <el-icon>
              <Upload />
            </el-icon>
            <span>新建出库单</span>
          </div>
          <div class="function-card purple">
            <el-icon>
              <Document />
            </el-icon>
            <a href="/AddGoods"><span>新建货品信息</span></a>
          </div>
          <div class="function-card orange">
            <el-icon>
              <Search />
            </el-icon>
            <span>新建仓库</span>
          </div>
        </div>
      </div>

      <!-- 中间区域 -->
      <div class="middle-section">
        <div class="top-section">
          <div class="operation-section">
            <h4>入库作业</h4>
            <div class="operation-grid">
              <a href="/InWareHouse">
              <div class="function-card blue">
                <el-icon>
                  <Search />
                </el-icon>
                <span>查看入库列表</span>
              </div>
              </a>
            </div>
          </div>

          <div class="operation-section">
            <h4>出入库作业</h4>
            <div class="operation-grid">
              <a href="/IOWareHouse">
              <div class="function-card green">
                <el-icon>
                  <Search />
                </el-icon>
                <span>查看出入库列表</span>
              </div>
              </a>
            </div>
          </div>
        </div>

        <div class="bottom-section">
          <h4>基础设置</h4>
          <div class="settings-grid">
            <div class="settings-item">
              <el-icon>
                <Goods />
              </el-icon>
              <span>商品管理</span>
            </div>
            <div class="settings-item">
              <el-icon>
                <User />
              </el-icon>
              <span>客户管理</span>
            </div>
            <div class="settings-item">
              <el-icon>
                <House />
              </el-icon>
              <span>仓库管理</span>
            </div>
            <div class="settings-item">
              <el-icon>
                <PriceTag />
              </el-icon>
              <span>库存盘点</span>
            </div>
          </div>
        </div>
      </div>

      <!-- 右侧仓库管理 -->
      <div class="right-section">
        <h3 class="section-title">仓库管理</h3>
        <div class="warehouse-grid">
          <div class="warehouse-item">
            <el-icon>
              <House />
            </el-icon>
            <span>仓库管理</span>
          </div>
          <div class="warehouse-item">
            <el-icon>
              <Box />
            </el-icon>
            <span>库存管理</span>
          </div>
          <div class="warehouse-item">
            <el-icon>
              <Lock />
            </el-icon>
            <span>库存冻结</span>
          </div>
          <div class="warehouse-item">
            <el-icon>
              <Switch />
            </el-icon>
            <span>移库管理</span>
          </div>
        </div>
      </div>
    </div>

    <!-- 图表区域 -->
    <div class="charts-section">
      <div class="chart-container">
        <div class="line-chart">
          <h4>一周业务数据</h4>
          <div class="chart-placeholder">
            <div class="chart-line blue"></div>
            <div class="chart-line green"></div>
            <div class="chart-line purple"></div>
            <div class="chart-labels">
              <span>出库</span>
              <span>入库</span>
              <span>物权</span>
            </div>
          </div>
        </div>

        <div class="line-chart">
          <h4>一周应收款统计</h4>
          <div class="chart-placeholder">
            <div class="chart-line blue"></div>
            <div class="chart-line purple"></div>
            <div class="chart-labels">
              <span>应收</span>
              <span>已收</span>
            </div>
          </div>
        </div>
      </div>

      <div class="donut-charts">
        <div class="donut-chart">
          <h4>本日已收/未收</h4>
          <div class="donut-placeholder">
            <div class="donut-circle">
              <div class="donut-segment blue" style="--percentage: 52%"></div>
              <div class="donut-segment purple" style="--percentage: 48%"></div>
            </div>
            <div class="donut-labels">
              <span>已收654 (52%)</span>
              <span>未收 (48%)</span>
            </div>
          </div>
        </div>

        <div class="donut-chart">
          <h4>本日已付/未付</h4>
          <div class="donut-placeholder">
            <div class="donut-circle">
              <div class="donut-segment blue" style="--percentage: 52%"></div>
              <div class="donut-segment purple" style="--percentage: 48%"></div>
            </div>
            <div class="donut-labels">
              <span>已付637 (52%)</span>
              <span>未付 (48%)</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">

import {
  ArrowDown,
  ArrowUp,
  List,
  Money,
  User,
  Download,
  Upload,
  Document,
  Search,
  Box,
  Folder,
  Switch,
  Setting,
  Van,
  Goods,
  House,
  PriceTag,
  Lock
} from '@element-plus/icons-vue'
</script>

<style scoped>
.dashboard {
  padding: 20px;
  background: #f4f6fa;
  min-height: 100vh;
}

/* KPI 区域样式 */
.kpi-section {
  display: flex;
  gap: 20px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.kpi-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  flex: 1;
  min-width: 200px;
}

.kpi-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
}

.kpi-icon.blue {
  background: #409eff;
}

.kpi-icon.green {
  background: #67c23a;
}

.kpi-icon.purple {
  background: #909399;
}

.kpi-icon.orange {
  background: #e6a23c;
}

.kpi-icon.red {
  background: #f56c6c;
}

.kpi-value {
  font-size: 24px;
  font-weight: bold;
  color: #303133;
}

.kpi-label {
  font-size: 14px;
  color: #606266;
}

/* 主要内容区域 */
.main-content {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 20px;
  margin-bottom: 30px;
}

.section-title {
  margin: 0 0 20px 0;
  font-size: 18px;
  font-weight: bold;
  color: #303133;
}

/* 左侧常用功能 */
.function-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.function-card {
  background: white;
  border-radius: 12px;
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.2s;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.function-card:hover {
  transform: translateY(-2px);
}

.function-card.blue {
  background: linear-gradient(135deg, #409eff, #66b1ff);
}

.function-card.green {
  background: linear-gradient(135deg, #67c23a, #85ce61);
}

.function-card.purple {
  background: linear-gradient(135deg, #909399, #a6a9ad);
}

.function-card.orange {
  background: linear-gradient(135deg, #e6a23c, #ebb563);
}

.function-card .el-icon {
  font-size: 30px;
  color: white;
}

.function-card span {
  color: white;
  font-weight: 500;
  text-align: center;
}

/* 中间区域 */
.middle-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.top-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.operation-section {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.operation-section h4 {
  margin: 0 0 15px 0;
  font-size: 16px;
  font-weight: bold;
  color: #303133;
}

.operation-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.operation-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  background: #f5f7fa;
  cursor: pointer;
  transition: background 0.2s;
}

.operation-item:hover {
  background: #ecf5ff;
}

.operation-item .el-icon {
  color: #409eff;
  font-size: 18px;
}

.operation-item span {
  color: #606266;
  font-size: 14px;
}

.bottom-section {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.bottom-section h4 {
  margin: 0 0 15px 0;
  font-size: 16px;
  font-weight: bold;
  color: #303133;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.settings-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  background: #f5f7fa;
  cursor: pointer;
  transition: background 0.2s;
}

.settings-item:hover {
  background: #ecf5ff;
}

.settings-item .el-icon {
  color: #409eff;
  font-size: 18px;
}

.settings-item span {
  color: #606266;
  font-size: 14px;
}

/* 右侧仓库管理 */
.warehouse-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.warehouse-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px;
  border-radius: 8px;
  background: white;
  cursor: pointer;
  transition: background 0.2s;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.warehouse-item:hover {
  background: #ecf5ff;
}

.warehouse-item .el-icon {
  color: #409eff;
  font-size: 18px;
}

.warehouse-item span {
  color: #606266;
  font-size: 14px;
}

/* 图表区域 */
.charts-section {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.chart-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.line-chart {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.line-chart h4 {
  margin: 0 0 15px 0;
  font-size: 16px;
  font-weight: bold;
  color: #303133;
}

.chart-placeholder {
  height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.chart-line {
  height: 4px;
  width: 80%;
  border-radius: 2px;
}

.chart-line.blue {
  background: #409eff;
}

.chart-line.green {
  background: #67c23a;
}

.chart-line.purple {
  background: #909399;
}

.chart-labels {
  display: flex;
  gap: 20px;
  font-size: 12px;
  color: #606266;
}

.donut-charts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.donut-chart {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.donut-chart h4 {
  margin: 0 0 15px 0;
  font-size: 16px;
  font-weight: bold;
  color: #303133;
}

.donut-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.donut-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  position: relative;
  background: conic-gradient(#409eff 0deg 187deg,
      #909399 187deg 360deg);
}

.donut-labels {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: #606266;
  text-align: center;
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .main-content {
    grid-template-columns: 1fr;
  }

  .chart-container {
    grid-template-columns: 1fr;
  }

  .charts-section {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .kpi-section {
    flex-direction: column;
  }

  .function-grid {
    grid-template-columns: 1fr;
  }

  .top-section {
    grid-template-columns: 1fr;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }
}

.welcome-card {
  margin-bottom: 24px;
  background: linear-gradient(90deg, #409eff 0%, #53c0ff 100%);
  color: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(64, 158, 255, 0.08);
}

.welcome-title {
  font-size: 26px;
  font-weight: bold;
  display: flex;
  align-items: center;
}
</style>
